<HTML>
<!-- =====================================================================

  File:      UserControls.htm for Adventure Works Cycles Storefront Sample
  Summary:   Self-documentation for application
  Date:	     June 16, 2003

=====================================================================

  This file is part of the Microsoft SQL Server Code Samples.
  Copyright (C) Microsoft Corporation.  All rights reserved.

This source code is intended only as a supplement to Microsoft
Development Tools and/or on-line documentation.  See these other
materials for detailed information regarding Microsoft code samples.

THIS CODE AND INFORMATION ARE PROVIDED "AS IS" WITHOUT WARRANTY OF ANY
KIND, EITHER EXPRESSED OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE
IMPLIED WARRANTIES OF MERCHANTABILITY AND/OR FITNESS FOR A
PARTICULAR PURPOSE.

======================================================= -->
    <head>
        <title>Adventure Works Cycles Store Documentation</title>
        <link rel="stylesheet" href="style.css">
    </head>
    <BODY>
        <h1>
            Background Information On User Controls
        </h1>
        <p>
            <STRONG>Overview : </STRONG>User Controls are user-developed controls that can 
            cleanly encapsulate UI/Functionality.&nbsp; They are implemented just like 
            regular .aspx pages (except that you typically don't want to add a wrapping 
            &lt;html&gt; or &lt;body&gt; tag around their content -- since they are 
            typically used <EM>within </EM>
        another page).&nbsp; Like regular .aspx pages, developers can sink the 
        "Page_Load" and "Page_Unload" events as well as utilize server controls within 
        them.
        <p>
            User Controls are used from another page by "registering" a unique prefixed tag 
            to the source location of the user control file.&nbsp; This is accomplished 
            using a "Register" page directive at the top of a .aspx file.&nbsp; For 
            example:
            <BLOCKQUOTE style="MARGIN-RIGHT: 0px">
                <p style="MARGIN-RIGHT: 0px">
					<font color="#2040a0"><strong><font color="4444FF"><strong>&lt;</strong></font><font color="#2040a0">%@</font> <font color="#2040a0">Register</font> <font color="#2040a0">TagPrefix=</font><font color="#444444">&quot;AdventureWorks&quot;</font> <font color="#2040a0">TagName=</font><font color="#444444">&quot;Menu&quot;</font> <font color="#2040a0">Src=</font><font color="#444444">&quot;_Menu.ascx&quot;</font> <font color="#2040a0">%</font><font color="4444FF"><strong>&gt;</strong></font></strong></font>
                </p>
            </BLOCKQUOTE>
        <p>
            They can then be declared and used as a server control within the page:
            <BLOCKQUOTE style="MARGIN-RIGHT: 0px">
                <p>
					<font color="#2040a0"><strong><font color="4444FF"><strong>&lt;</strong></font><font color="#2040a0">AdventureWorks:Menu</font> <font color="#2040a0">id=</font><font color="#444444">&quot;Menu1&quot;</font> <font color="#2040a0">runat=</font><font color="#444444">&quot;server&quot;</font> <font color="#2040a0">/</font><font color="4444FF"><strong>&gt;</strong></font></strong></font>
                </p>
            </BLOCKQUOTE>
        <p>
            Note that all public properties/fields declared within the code portion of a 
            user control are programmable from the page on which it is used (a page 
            developer would use the "id" attribute of the user control to set the 
            properties -- for example: MyMenu.SourceFile="Default.src").&nbsp; These 
            properties/fields can also be declaratively set.&nbsp; For example:
            <BLOCKQUOTE style="MARGIN-RIGHT: 0px">
                <p>
					<font color="#2040a0"><strong><font color="4444FF"><strong>&lt;</strong></font><font color="#2040a0">AdventureWorks:Menu</font> <font color="#2040a0">id=</font><font color="#444444">&quot;MyMenu&quot;</font> <font color="#2040a0">SourceFile=</font><font color="#444444">&quot;Default.src&quot;</font> <font color="#2040a0">runat=</font><font color="#444444">&quot;server&quot;</font> <font color="#2040a0">/</font><font color="4444FF"><strong>&gt;</strong></font></strong></font>
                </p>
            </BLOCKQUOTE>
        <p>
            Look at the source of different pages within the Adventure Works Cycles application to see how 
            the Header, Menu, ReviewList, AlsoBought and PopularItems user controls are being used.
        </p>
    </BODY>
</HTML>
